#pragma once

#include <iostream>
using namespace std;

struct ListNode
{
	int value;
	ListNode* NextNode;

	ListNode(int Invalue, ListNode* InNode)
	{
		value = Invalue;
		NextNode = InNode;
	}
};

class CListReverse
{

public:
	static void PrintList(ListNode* InHead)
	{
		ListNode* Tmp = InHead;
		while (Tmp)
		{
			printf("%d", Tmp->value);
			if (Tmp->NextNode)
			{
				printf("--->");
			}
			Tmp = Tmp->NextNode;
		}
		cout << endl;
	}

	static ListNode* ListReverse(ListNode* InHead)
	{
		ListNode* CurrentNode = InHead;
		ListNode* PreNode = nullptr;
		ListNode* NextNodePar = nullptr;

		while (CurrentNode)
		{
			NextNodePar = CurrentNode->NextNode;
			CurrentNode->NextNode = PreNode;
			PreNode = CurrentNode;
			CurrentNode = NextNodePar;
		}
		return PreNode;
	}
};

